import tkinter as tk
from views import AboutFrame,ChangeFrame,InsertFrame,SearchFrame,DeleteFrame

class MainPage :
    def __init__(self, master:tk.Tk):
        self.root = master
        self.root.title("学生管理系统 v1.1.1.1")
        self.root.geometry('600x400')
        self.create_page()
    def create_page(self):
        self.insert_frame =InsertFrame(self.root)  # 页面已经封装过了
        self.search_frame = SearchFrame(self.root)  # 页面已经封装过了
        self.delete_frame = DeleteFrame(self.root)  # 页面已经封装过了
        self.about_frame = AboutFrame(self.root)#页面已经封装过了
        #tk.Label(self.about_frame,text='关于作品：tkinter制作').pack()
       # tk.Label(self.about_frame, text='关于作者：zkj 制作').pack()
        self.change_frame = ChangeFrame(self.root)
        #tk.Label(self.change_frame, text='这是修改页面').pack()


        menubar = tk.Menu(self.root)
        menubar.add_command(label='录入',command=self.show_insert)
        menubar.add_command(label='查询',command=self.show_search)
        menubar.add_command(label='删除',command=self.show_delete)
        menubar.add_command(label='修改',command=self.show_change)
        menubar.add_command(label='关于',command=self.show_about)
        self.root['menu'] = menubar




    def show_insert(self):
        self.about_frame.pack_forget()
        self.insert_frame.pack()
        self.search_frame.pack_forget()
        self.delete_frame.pack_forget()
        self.about_frame.pack_forget()
        self.change_frame.pack_forget()
    def show_search(self):
        self.about_frame.pack_forget()
        self.insert_frame.pack_forget()
        self.search_frame.pack()
        self.delete_frame.pack_forget()
        self.about_frame.pack_forget()
        self.change_frame.pack_forget()

    def show_delete(self):
        self.about_frame.pack_forget()
        self.insert_frame.pack_forget()
        self.search_frame.pack_forget()
        self.delete_frame.pack()
        self.about_frame.pack_forget()
        self.change_frame.pack()


    def show_change(self):
        self.about_frame.pack_forget()
        self.insert_frame.pack_forget()
        self.search_frame.pack_forget()
        self.delete_frame.pack_forget()
        self.about_frame.pack_forget()
        self.change_frame.pack()
    def show_about(self):
        self.about_frame.pack_forget()
        self.insert_frame.pack_forget()
        self.search_frame.pack_forget()
        self.delete_frame.pack_forget()
        self.about_frame.pack()
        self.change_frame.pack_forget()


if __name__ == '__main__':
    root = tk.Tk()
    MainPage(root)
    root.mainloop()